<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <ui:composition>
        <p:dataTable id="tbl_fcs" var="fc" rowIndexVar="row" value="#{fCBViewBean.fcb.fileCards}" rowKey="#{fc.id}"
                     selection="#{fCBViewBean.sfc}" selectionMode="single">
            <p:ajax event="rowSelect" listener="#{fCBViewBean.onRowSelect}" update=":frm_nfc"/>
            <p:ajax event="rowUnselect" listener="#{fCBViewBean.onRowUnselect}" update=":frm_nfc"/>
            <p:column>
                <f:facet name="header">
                    <h:outputText value="#{msg.filecardbox_tbl_fcs_col_num_header_value}"/>
                </f:facet>
                <h:outputText value="#{row + 1}"/>
            </p:column>
            <p:column>
                <f:facet name="header">
                    <h:outputText value="#{msg.filecardbox_tbl_fcs_col_qu_header_value}"/>
                </f:facet>
                <h:outputText value="#{fc.question}"/>
            </p:column>
            <p:column>
                <f:facet name="header">
                    <h:outputText value="#{msg.filecardbox_tbl_fcs_col_aw_header}"/>
                </f:facet>
                <h:outputText value="#{fc.answer}"/>
            </p:column>
        </p:dataTable>
        <p:separator/>
        <h:form id="frm_nfc">
            <p:fieldset id="fs_edit" legend="#{msg.filecardbox_fs_edit_legend}">
                <p:panelGrid columns="3" styleClass="noborder">
                    <p:outputLabel id="lbl_qu" for="txta_qu" value="#{msg.filecardbox_lbl_qu_value}"/>
                    <p:inputTextarea id="txta_qu" value="#{fCBViewBean.fc.question}"/>
                    <p:message for="txta_qu" showDetail="true"/>
                    <p:outputLabel id="lbl_aw" for="txta_aw" value="#{msg.filecardbox_lbl_aw_value}"/>
                    <p:inputTextarea id="txta_aw" value="#{fCBViewBean.fc.answer}"/>
                    <p:message for="txta_aw" showDetail="true"/>
                </p:panelGrid>
                <p:commandButton id="btn_save" value="#{msg.btn_save}" actionListener="#{fCBViewBean.saveFileCard()}" update="fs_edit, :tbl_fcs"/>
                <p:commandButton id="btn_cancel" value="#{msg.btn_cancel}" actionListener="#{fCBViewBean.cancelFileCard()}" update="fs_edit, :tbl_fcs"/>
                <p:commandButton id="btn_delete" value="#{msg.btn_delete}" actionListener="#{fCBViewBean.deleteFileCard()}" rendered="#{fCBViewBean.fc.id != null}" update="fs_edit, :tbl_fcs"/>
                <p:commandButton id="btn_new" value="#{msg.btn_new}" actionListener="#{fCBViewBean.cancelFileCard()}" rendered="#{fCBViewBean.fc.id != null}" update="fs_edit, :tbl_fcs"/>
            </p:fieldset>
        </h:form> 
    </ui:composition>
</html>

